
 
from pydantic import BaseModel,FilePath,Field
from langchain_core.utils.pydantic import (
    PydanticBaseModel,
    TBaseModel,
)

from langchain_core.beta.runnables.context import Context
from langchain_core.runnables.passthrough import RunnablePassthrough
from langchain_core.prompts.prompt import PromptTemplate
from langchain_core.output_parsers.string import StrOutputParser
from langchain.schema import HumanMessage, SystemMessage
 
 
from langchain.chat_models import ChatOpenAI
from langchain.output_parsers import PandasDataFrameOutputParser, OutputFixingParser
from langchain_core.prompts import PromptTemplate
import pandas as pd

from langchain_core.example_selectors import (
    LengthBasedExampleSelector,
    MaxMarginalRelevanceExampleSelector,
    SemanticSimilarityExampleSelector,
)
from langchain_core.prompts import (
    AIMessagePromptTemplate,
    BaseChatPromptTemplate,
    BasePromptTemplate,
    ChatMessagePromptTemplate,
    ChatPromptTemplate,
    FewShotChatMessagePromptTemplate,
    FewShotPromptTemplate,
    FewShotPromptWithTemplates,
    HumanMessagePromptTemplate,
    MessagesPlaceholder,
    PipelinePromptTemplate,
    PromptTemplate,
    StringPromptTemplate,
    SystemMessagePromptTemplate,
    load_prompt,
)

from langchain._api import create_importer
from langchain.prompts.prompt import Prompt

llm = ChatOpenAI(
    model="deepseek-chat",
    temperature=0,
    openai_api_key="sk-605e60a1301040759a821b6b677556fb",
    base_url="https://api.deepseek.com/v1")

prompt = ChatPromptTemplate.from_template("tell me a joke about {topic}")
parser = StrOutputParser()
chain = prompt | llm | parser

for chunk in chain.stream({"topic": "parrot"}):
    print(chunk, end="|", flush=True)


